<div id="tableau">
	<h4>Récent</h4>
	<?php
	$req = $bdd->query('SELECT * FROM textes');
	$donnees = $req->fetch();
	?>
	<p><b><?php echo $donnees['titre']; ?></b><br/>
	<?php
	$req_cat = $bdd->prepare('SELECT * FROM categories_textes WHERE id=:id');
	$req_cat->execute(array('id' => $donnees['categorie']));
	$donnees_cat = $req_cat->fetch();
	echo $donnees_cat['nom']; 
	?>
	</p>
	<p><?php //echo substr($donnees['texte'], 100, 250); ?></p>
	<p><a href="index.php?page=textes&id=<?php echo $donnees['id']; ?>">Lire</a></p>
	<?php
	$req->closeCursor();
	?>
</div>
<div id="tableau">
	<h4>Au hasard</h4>
	<?php
	$req = $bdd->query('SELECT COUNT(id) AS nombre_textes_total FROM textes');
	$donnees = $req->fetch();
	$nombre_textes_total=($donnees['nombre_textes_total']-1);
	$hasard=rand(1,$nombre_textes_total);
	$req = $bdd->prepare('SELECT * FROM textes WHERE id=:id');
	$req->execute(array('id' => $hasard));
	$donnees = $req->fetch();
	?>
	<p><b><?php echo $donnees['titre']; ?></b><br/>
	<?php
	$req_cat = $bdd->prepare('SELECT * FROM categories_textes WHERE id=:id');
	$req_cat->execute(array('id' => $donnees['categorie']));
	$donnees_cat = $req_cat->fetch();
	echo $donnees_cat['nom']; 
	?>
	</p>
	<p><?php //echo substr($donnees['texte'], 100, 250); ?></p>
	<p><a href="index.php?page=textes&id=<?php echo $donnees['id']; ?>">Lire</a></p>
	<?php
	$req->closeCursor();
	?>
</div>
<hr />


